package com.hubu.blog.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * VIP套餐表 表定义层。
 *
 * @author 331126135@qq.com
 * @since 2025-06-10
 */
public class VipPlanTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * VIP套餐表
     */
    public static final VipPlanTableDef VIP_PLAN = new VipPlanTableDef();

    /**
     * 套餐ID，雪花算法生成
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 套餐价格
     */
    public final QueryColumn PRICE = new QueryColumn(this, "price");

    /**
     * 状态
     */
    public final QueryColumn STATUS = new QueryColumn(this, "status");

    /**
     * VIP类型
     */
    public final QueryColumn VIP_TYPE = new QueryColumn(this, "vip_type");

    /**
     * 有效期(天)
     */
    public final QueryColumn DURATION = new QueryColumn(this, "duration");

    /**
     * 套餐代码(如annual_svip)
     */
    public final QueryColumn PLAN_CODE = new QueryColumn(this, "plan_code");

    /**
     * 套餐名称(如年度SVIP)
     */
    public final QueryColumn PLAN_NAME = new QueryColumn(this, "plan_name");

    /**
     * VIP等级(1-10)
     */
    public final QueryColumn VIP_LEVEL = new QueryColumn(this, "vip_level");

    /**
     * 是否删除：0-未删除 1-已删除
     */
    public final QueryColumn IS_DELETED = new QueryColumn(this, "is_deleted");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 删除时间
     */
    public final QueryColumn DELETE_TIME = new QueryColumn(this, "delete_time");

    /**
     * 套餐特权(JSON格式)
     */
    public final QueryColumn PRIVILEGES = new QueryColumn(this, "privileges");

    /**
     * 更新时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 套餐描述
     */
    public final QueryColumn DESCRIPTION = new QueryColumn(this, "description");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, PLAN_NAME, PLAN_CODE, VIP_TYPE, VIP_LEVEL, DURATION, PRICE, DESCRIPTION, PRIVILEGES, STATUS, CREATE_TIME, UPDATE_TIME, DELETE_TIME};

    public VipPlanTableDef() {
        super("db_blog", "blog_vip_plan");
    }

    private VipPlanTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public VipPlanTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new VipPlanTableDef("db_blog", "blog_vip_plan", alias));
    }

}
